import {
    createApp,
    ref
} from "vue";
import "./style.css";
import "./style-color.css";
import App from "./App.vue";
import router from "./router";
import pinia from "./stores/index";

import messageManager from "./manager/messageManager";
import loadingManager from "./manager/loadingManager";



const app = createApp(App);

app.use(pinia);
app.use(router);

// 屏蔽警告
app.config.warnHandler = () => null;

window.router = router;
window.ref = ref;

app.mount("#app");


new messageManager();
new loadingManager();

window.messageBox = messageManager;
window.loading = loadingManager;




document.addEventListener('plusready', function () {
    var first = null;
    plus.key.addEventListener('backbutton', function () {
        if (!first) {
            first = new Date().getTime();
            if (history) {
                history.back(-1);
            } else {
                router.back(-1);
            }
            setTimeout(() => {
                first = null;
            }, 500);
        } else {
            if (new Date().getTime() - first < 500) {
                plus.runtime.quit();
            }
        }
    })
})